<template>
    <div>
        
        岗位名称:<el-input v-model="form.name" style="width: 240px" placeholder="Please input" />
        <el-button @click="backed">取消</el-button>
        <el-button type="primary" @click="submit">确定</el-button>
    </div>
</template>

<script setup lang="ts">
import { reactive } from 'vue';
import  {  addCompany, editPremsd } from '../../apis/post/post';
import router from '../../router';
import { onMounted } from 'vue';
import { editCompany } from '../../apis/post/post';

onMounted(()=>{
  form.id=Number(router.currentRoute.value.query.id)
  console.log(form.id);
  getdata()
})
const id=Number(router.currentRoute.value.query.id)
// const input = ref('')
const form=reactive({
  id:0,
  name:'',
})
const getdata=()=>{
    editCompany(id).then((res:any)=>{
        console.log(res);
        form.name=res.name
    })
}
const submit=()=>{
    if(id==0){
        addCompany(form).then(res=>{
            console.log(res);
            router.back()
        })
    }else{
        editPremsd(form).then(res=>{
            console.log(res);
            router.back()
        })
    }
  
 
}

const backed=()=>{
  router.back()
}
</script>

<style scoped>

</style>